﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Handrise.CDCable.Mobile.Business
{
    /// <summary>
    /// 系统配置服务
    /// </summary>
    public class SysConfigService
    {
        /// <summary>
        /// 获取一个系统配置信息
        /// </summary>
        /// <param name="keyName">键值</param>
        /// <returns></returns>
        public SysConfig GetSysConfig(string keyName)
        {
            return AppLogic.dataService.GetFirstEntity<SysConfig>("KeyName = '" + keyName + "'", "");
        }

        /// <summary>
        /// 更新系统参数
        /// </summary>
        /// <param name="sysConfig"></param>
        /// <returns></returns>
        public void UpdateSysConfig(SysConfig sysConfig)
        {
            if (AppLogic.dataService.Add<SysConfig>(sysConfig) != 1)
                AppLogic.dataService.Update<SysConfig>(sysConfig);
        }
    }
}
